package com.wangp.mywrite.inwork.pattern._5._5_2_or;

/***
 * @author wangpeng
 * @since 2022-03-03  14:38
 */
public class OrChar {


    private final static String YEAR = "1922";

    public static void main(String[] args) {

        String yearReg = "19|20\\d{2}";
        System.out.println(YEAR + " 与 " + yearReg + " 匹配结果： " + YEAR.matches(yearReg));

        // 为什么如上正则没有匹配上呢？ 因为正则表示含义是 19 或者 22\d{2}，做如下修改
        String yearReg2 = "(19|20)\\d{2}";
        System.out.println(YEAR + " 与 " + yearReg2 + " 匹配结果： " + YEAR.matches(yearReg2));
    }
}
